package main

import (
	"backEnd/controller"
	"backEnd/dto"
	"backEnd/middleware"

	"github.com/gin-gonic/gin"
)

func CollectRoute(r *gin.Engine) *gin.Engine {
	// 用户路由
	r.POST("/user/register/phone", controller.PhoneRegister)
	r.POST("/user/register/verify", middleware.VerifyAuthMiddleware(), controller.Verification)
	r.POST("/user/login", controller.Login)
	r.POST("/user/info", middleware.UserAuthMiddleware(), controller.Info)
	r.POST("/finduser", dto.GetUserById)
	r.POST("/user/update", middleware.UserAuthMiddleware(), controller.UpdateUser)
	r.POST("/user/update/password", middleware.UserAuthMiddleware(), controller.UpdatePassword)
	r.POST("/user/published", middleware.UserAuthMiddleware(), controller.GetPublishedProductsByUser)
	r.POST("/user/authentication", middleware.UserAuthMiddleware(), controller.Authentication)

	// 商品相关的路由
	r.POST("/product/publish", middleware.UserAuthMiddleware(), controller.Publish)
	r.POST("/product/detail", middleware.UserAuthMiddleware(), controller.Detail)
	r.POST("/product/update", middleware.UserAuthMiddleware(), controller.UpdateProduct)
	r.POST("/product/delist", middleware.UserAuthMiddleware(), controller.Delist)
	r.POST("/product/report", middleware.UserAuthMiddleware(), controller.Report)
	r.POST("/product/audit", middleware.UserAuthMiddleware(), controller.Report)

	//预览页
	r.POST("/page", controller.Page)

	//图片接收
	r.POST("/img/upload", controller.UploadCoverImg)

	//审核路由
	r.POST("/admin/verify/productlist", controller.ShowAuditProducts)
	r.POST("/admin/verify/productid", middleware.AdminAuthMiddleware(), controller.AuditProduct)
	r.POST("/admin/verify/userlist", controller.ShowAuthentications)
	r.POST("/admin/verify/userid", middleware.AdminAuthMiddleware(), controller.ShowAuthentications)
	return r
}
